<template>
	<view style="padding: 20rpx;">
		<image :src="news.avatar" style="width: 100%; height: 200rpx; object-fit: cover; border-radius: 10rpx;" />
		<view style="font-size: 36rpx; font-weight: bold; margin: 20rpx 0;">{{ news.title }}</view>
		<view style="font-size: 28rpx; color: #666; line-height: 1.5;">
			{{ news.content }}
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				news: {}
			}
		},
		onLoad(options) {
			console.log('Received id:', options.id); // 确保 id 被正确接收
			this.loadNewsDetail(options.id)
		},
		methods: {
			loadNewsDetail(id) {
			    this.$request.post(`/news/selectById/${id}`).then(res => {
			        if (res.code === '200') {
			            this.news = res.data || {};
			        } else {
			            console.error('获取新闻详情失败:', res.msg);
			        }
			    }).catch(error => {
			        console.error('请求失败:', error);
			    });
			}

		}
	}
</script>

<style>
</style>
